<?php

/**
 * Simple Class To Handle Logs
 * 
 * @todo Add Log Rotator / Max Size - Some Are Getting Big
 *
 */
class Log
{
	public static $log = false;
	
	public static function logFile($logName) {
		return Plex::$BASE_DIR . Config::get("Plex","log_dir") . "/" . $logName . ".txt";
	}
	
	public static function append($logName, $msg) {
		if(self::$log) {
			file_put_contents(self::logFile($logName),date(Config::get("Plex","log_date_format")) . " -- {$_SERVER['REMOTE_ADDR']} -- " . $msg."\r\n",FILE_APPEND);
		}
		
	}
	
	public static function clear($logName) {
		file_put_contents(self::logFile($logName),"");
	}	
}